package com.hs.service.impl;

import com.hs.entity.Course;
import com.hs.entity.Grade;
import com.hs.mapper.CourseMapper;
import com.hs.mapper.GradeMapper;
import com.hs.service.GradeService;
import com.hs.service.SequenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GradeServiceImpl implements GradeService {

    @Autowired
    private GradeMapper gradeMapper;

    //查询学生成绩信息列表
    @Override
    public List<Grade> findGradeList(String searchKey) {
        return gradeMapper.findGradeList(searchKey);
    }

    //录入平时成绩和考试成绩
    @Override
    public Integer setGrade(Integer id,String usualscore,String testscore){
        double usualscore1 = Double.parseDouble(usualscore);
        double testscore1 = Double.parseDouble(testscore);
        double score1 = 0.3*usualscore1+0.7*testscore1;
        String score = String.valueOf(score1);
        return gradeMapper.setGrade(id,usualscore,testscore,score);
    }

    //根据id查询成绩
    @Override
    public Grade findGradeById(Integer id){
        return gradeMapper.selectByPrimaryKey(id);
    }

}
